//
//  JAGFeedVideoView.h
//  JAGatherAdSDK
//
//  Created by Yc on 2024/3/1.
//

#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

@protocol JAGFeedVideoViewDelegate <NSObject>

@optional

/// 视频准备播放
- (void)feedVideoReady;

/// 视频开始播放
- (void)feedVideoStart;

/// 视频暂停播放
- (void)feedVideoPause;

/// 视频恢复播放
- (void)feedVideoResume;

/// 视频播放完成
- (void)feedVideoFinish;

/// 视频播放出错
- (void)feedVideoError:(NSError *)error;

@end

typedef NS_ENUM(NSUInteger, JAGFeedVideoViewStatus) {
    JAGFeedVideoViewStatusDefault,
    JAGFeedVideoViewStatusReady,
    JAGFeedVideoViewStatusStarted,
    JAGFeedVideoViewStatusFinished,
    JAGFeedVideoViewStatusPaused,
    JAGFeedVideoViewStatusResumed,
    JAGFeedVideoViewStatusError,
};


@interface JAGFeedVideoView : UIView

/// 视屏静音 默认 YES
@property (nonatomic, assign) BOOL muted;

/// 视屏自动播放 默认 YES
@property (nonatomic, assign) BOOL isAutoPlay;

/// 视屏是否播放中
@property (nonatomic, assign, readonly) BOOL isPlaying;

/// 视屏播放状态
@property (nonatomic, assign, readonly) JAGFeedVideoViewStatus status;

/// 代理
@property (nonatomic, weak) id<JAGFeedVideoViewDelegate> delegate;

/// 播放状态变更回调
@property (nonatomic, copy) void (^feedVideoViewStatusBlock)(JAGFeedVideoViewStatus status ,NSError *error);

/// 加载视频资源
/// - Parameters:
///   - imageURL: 封面Url
///   - videoURL: 视屏Url
- (void)loadCoverImageURL:(NSURL *)imageURL videoURL:(NSURL *)videoURL;

/// 播放视频
- (void)playVideo;

/// 恢复播放视频
- (void)resumeVideo;

/// 暂停视频
- (void)pauseVideo;

/// 视频广告时长，单位 s
- (NSTimeInterval)totalTime;

/// 视频广告已播放时长，单位 s
- (NSTimeInterval)currentTime;

@end

NS_ASSUME_NONNULL_END
